#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int add(int a, int b) { return a + b; }

int sub(int a, int b) { return a - b; }
int cheng(int a, int b) { return a * b; }

int div2(int a, int b) { return a / b; }

int opt2num(int a, int b, int (*p)(int, int)) { return p(a, b); }
int main(int argc, char *argv[]) {
  if (argc != 4) {
    printf("应该是四个参数\n");
    return 0;
  }
  int (*p)(int, int);
  char *opt = argv[2];
  if (strcmp(opt, "+") == 0) {
    p = add;
  } else if (strcmp(opt, "-") == 0) {
    p = sub;
  } else if (strcmp(opt, "x") == 0) {
    p = cheng;
  } else if (strcmp(opt, "/") == 0) {
    p = div2;
  } else {
    printf("仅支持四则运算\n");
  }
  printf("%s %s %s = %d\n", argv[1], opt, argv[3],
         opt2num(atoi(argv[1]), atoi(argv[3]), p));

  return 1;
}
